package com.hanbang.maige.pressenter.quanzi;

import com.hanbang.maige.mode.HttpRequest;
import com.hanbang.maige.mode.httpresponse.HttpResult;
import com.hanbang.maige.mode.javabean.quanzi.QuanZiData;
import com.hanbang.maige.pressenter.PublicPresenter;
import com.hanbang.maige.utils.http.httpquest.HttpCallBack;
import com.hanbang.maige.utils.http.httpquest.HttpRequestParam;
import com.hanbang.maige.view.quanzi.IQuanZiBaseView;

import java.util.List;

/**
 * 作者　　: 李坤
 * 创建时间:2016/9/19　17:05
 * 邮箱　　：496546144@qq.com
 * <p>
 * 功能介绍：
 */

public class QuanZiPresenter extends PublicPresenter<IQuanZiBaseView.IQuanZiView> {

    /**
     * 作者　　: 李坤
     * 创建时间: 2016/11/1 17:29
     * <p>
     * 方法功能：朋友圈主页	friendquanList
     */

    public void getHttpData(final boolean isStart) {
        if (isStart) {
            mvpView.clearPagingData();
        }
        HttpCallBack.Buider buider = new HttpCallBack.Buider(this);
        buider.setShowLoadding(false);
        buider.setSwipeRefreshLayout(mvpView.getSwipeRefreshLayout());
        buider.setLoadingAndRetryManager(mvpView.getLoadingAndRetryManager());
        HttpCallBack<HttpResult<List<QuanZiData>>> callBack = new HttpCallBack<HttpResult<List<QuanZiData>>>(buider) {
            @Override
            public void onSuccess(HttpResult<List<QuanZiData>> result) {
                super.onSuccess(result);

                if (result.isSucceed()) {
                    if (isStart) {
                        mvpView.clearData();
                    }

                    mvpView.updataUI((List<QuanZiData>) mvpView.getValidData(result.getData()));
                }
            }
        };

        HttpRequestParam param = new HttpRequestParam("friendquanList");
        param.addPaging(mvpView.getPagingHelp());
        mvpView.addSubscription(HttpRequest.executeGet(callBack, param));

    }

}
